package cn.sunshine.ymcc.web.controller;

import cn.sunshine.ymcc.dto.SmsCodeDTO;

import cn.sunshine.ymcc.result.JSONResult;
import cn.sunshine.ymcc.service.IVerifycodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author: Eric
 * @CreateTime: 2022-08-06  10:21
 * @Description:
 */

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {


    @Autowired
    private IVerifycodeService verifycodeService;

    /*
     * @Title: sendSmsCode
     * @Description: 短信验证码
     * @Author: Mr.Jiang
     * @Version: 1.0
     * @Date:  2022/8/7 22:57
     * @Parameters: [dto]
     * @Return cn.sunshine.ymcc.result.JSONResult
     */
    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid SmsCodeDTO dto) {
        return verifycodeService.sendSmsCode(dto);
    }

    /*
     * @Title: sendimageCode
     * @Description: 图形验证码
     * @Author: Mr.Jiang
     * @Version: 1.0
     * @Date:  2022/8/7 22:56
     * @Parameters: [key]
     * @Return cn.sunshine.ymcc.result.JSONResult<java.lang.String>
     */
    @GetMapping("/imageCode/{key}")
    public JSONResult sendimageCode(@PathVariable String key) {
        String s = verifycodeService.sendimageCode(key);
        return JSONResult.success(s);

    }
}
